<template>
	<view>
		<view class="cu-list menu" :class="['card-menu margin-top']"  >
			<view class="cu-item  "  >
				<view class="content"> 
					<text class="text-grey">{{i18n.wei.title}}</text>
				</view>
			</view>
			<view class="cu-list grid col-1 no-border">
				<view class="cu-item text-left">
					<text class="text-xs nowrap" style="margin-left: 9px;">{{i18n.wei.info}}</text>
					<view style="margin-left: 9px;">
						<view class="text-df row"> </view>
					</view>
				</view>
				 
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				timer:[],
			}
		},
		computed: {
			...mapState({
				userinfo: state => state.user.userinfo,
				myconfig: state => state.user.myconfig
			}),
			i18n() {
				return this.$t('message');
			}
		},
		onLoad() {
		    uni.setNavigationBarTitle({
            	title: this.i18n.wei.title
        	});
		},
		methods: {
			...mapActions(['myConfig','SAVE_HOME_PRODUCTS']),
			init(){
				this.cleartimer();
				let tt = setInterval((e) => {
					if(this.myconfig.preserve==2){
						this.wei();
					} 
					return Promise.all([this.myConfig()])
				}, 3000);
				this.timer.push(tt) 
				
			},
			cleartimer() {
				console.log(this.timer.length)
				if (this.timer.length > 0) {
					for (let i = 0; i < this.timer.length; i++) {
						clearInterval(this.timer[i])
					}
					this.timer = []
				}
			},
			wei() {
				this.cleartimer();
				//首页
				uni.switchTab({
					url: '/pages/index/index'
				}) 
			},
			onBackPress(e) {
				// 这里可以自定义返回逻辑，比如下面跳转其他页面 
				// uni.switchTab({ 
				// 	url: '/pages/index/index'
				// })
				// return true 表示禁止默认返回
				return true
			}, 
		},
		onShow() {
			this.init();
		},
		onHide() {
			this.cleartimer();
		},
	}
</script>

<style>

</style>
